//获取url中的参数
function getUrlParam(name) {
  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
  var r = window.location.search.substr(1).match(reg); //匹配目标参数
  if (r != null) return unescape(r[2]);
  return null; //返回参数值
}

// 获取当前日期
function getDate() {
  var mydate = new Date();
  var str = "" + mydate.getFullYear() + "-";
  let month = "";
  let day = "";
  if (mydate.getMonth() < 10) {
    month = "0" + (mydate.getMonth() + 1);
  } else {
    month = mydate.getMonth() + 1;
  }
  if (mydate.getDate() < 10) {
    day = "0" + mydate.getDate();
  } else {
    day = mydate.getDate();
  }
  str += month + "-";
  str += day;
  return str;
}

// 2020-02-17 start
// 获取当前日期 + 时间
function getDateTime() {
  var mydate = new Date();
  var str = "" + mydate.getFullYear() + "-";
  let month = "";
  let day = "";
  let hours = mydate.getHours(); // 获取当前小时数(0-23)
  let min = mydate.getMinutes(); // 获取当前分钟数(0-59)
  let sec = mydate.getSeconds(); // 获取当前秒数(0-59)
  if (mydate.getMonth() < 10) {
    month = "0" + (mydate.getMonth() + 1);
  } else {
    month = mydate.getMonth() + 1;
  }
  if (mydate.getDate() < 10) {
    day = "0" + mydate.getDate();
  } else {
    day = mydate.getDate();
  }
  str += month + "-";
  str += day + " ";
  str += hours + ":";
  str += min + ":";
  str += sec;
  return str;
}
// 2020-02-17 end

// 昨天的日期
function getPreDate(dayNum) {
  var day1 = new Date();
  day1.setTime(day1.getTime() - (dayNum || 1) * 24 * 60 * 60 * 1000);
  let month = "";
  let day = "";
  if (day1.getMonth() < 10) {
    month = "0" + (day1.getMonth() + 1);
  } else {
    month = day1.getMonth() + 1;
  }
  if (day1.getDate() < 10) {
    day = "0" + day1.getDate();
  } else {
    day = day1.getDate();
  }
  var s1 = day1.getFullYear() + "-" + month + "-" + day;
  return s1;
}
// 指定日期的前多少天日期
function specifiedPreDate(date, dayNum) {
  var day1 = new Date(date);
  day1.setTime(day1.getTime() - (dayNum || 1) * 24 * 60 * 60 * 1000);
  let month = "";
  let day = "";
  if (day1.getMonth() < 10) {
    month = "0" + (day1.getMonth() + 1);
  } else {
    month = day1.getMonth() + 1;
  }
  if (day1.getDate() < 10) {
    day = "0" + day1.getDate();
  } else {
    day = day1.getDate();
  }
  var s1 = day1.getFullYear() + "-" + month + "-" + day;
  return s1;
}

// 指定日期的后多少天日期
function specifiedNextDate(date, dayNum) {
  var day1 = new Date(date);
  day1.setTime(day1.getTime() + (dayNum || 1) * 24 * 60 * 60 * 1000);
  let month = "";
  let day = "";
  if (day1.getMonth() < 10) {
    month = "0" + (day1.getMonth() + 1);
  } else {
    month = day1.getMonth() + 1;
  }
  if (day1.getDate() < 10) {
    day = "0" + day1.getDate();
  } else {
    day = day1.getDate();
  }
  var s1 = day1.getFullYear() + "-" + month + "-" + day;
  return s1;
}